﻿namespace Core.Infra.Data.Maps {
    using System;
    using Business.Domain.Entities;
    using FluentNHibernate.Mapping;

    public class LancamentoMap : ClassMap<Lancamento>{
        public LancamentoMap() {
            Table("tbl_Lancamento");

            Id(x => x.Id);

            Map(x => x.Comentario)
                .Not.Nullable();
            Map(x => x.Valor)
                .Not.Nullable();
            Map(x => x.Vencimento)
                .Not.Nullable();
            Map(x => x.Situacao)
                .CustomType<TipoSituacao>()
                .Not.Nullable();

            References(x => x.Categoria, "IdCategoria").Nullable();
            References(x => x.Conta, "IdConta").Not.Nullable();
            References(x => x.Favorecido, "IdFavorecido").Nullable();            

            DiscriminateSubClassesOnColumn<int>("IdTipoLancamento", -1);
        }
    }

    public class DepositoMap : SubclassMap<Deposito> {
        public DepositoMap() {
            DiscriminatorValue(1);
        }
    }

    public class SaqueMap : SubclassMap<Saque> {
        public SaqueMap() {
            DiscriminatorValue(2);
        }
    }

    //public class TransferenciaMap : SubclassMap<Transferencia> {
    //    public TransferenciaMap() {
    //        DiscriminatorValue(3);
    //    }
    //}
}
